package com.ys.service.sys.impl;

import java.util.Date;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.bo.util.DateUtil;
import com.bo.vo.R;
import com.ys.dto.EditDto;
import com.ys.entity.sys.TbStaticConfig;
import com.ys.mapper.sys.TbStaticConfigMapper;
import com.ys.service.sys.TbStaticConfigService;

@Service("tbStaticConfigService")
public class TbStaticConfigServiceImpl implements TbStaticConfigService {
	@Autowired
	private TbStaticConfigMapper tbStaticConfigMapper;
	
	@Override
	public R edit(Map<String, Object> params) {

		TbStaticConfig entity = JSON.parseObject(JSON.toJSONString(params), TbStaticConfig.class);
		tbStaticConfigMapper.update(entity);
		
		return R.ok(EditDto.closeAndReload());
	}

	@Override
	public void updateRefreshAmazonOrderFinishiTime() {
		TbStaticConfig entity = new TbStaticConfig()
				.setKeyOne("refresh-amazon-shop-order")
				.setKeyTwo("finishi-time")
				.queryFirst();
		entity.setName(DateUtil.getYYYY_MM_DD_HH_mm_ss(new Date()));
		tbStaticConfigMapper.update(entity);
	}

}
